package create.prototype;

import java.util.Hashtable;

/**
 * 对象缓存，启动的时候创建比较难创建的对象并放入缓存中
 */
public class AnimalCache {
	private static final Hashtable<String, Animal> shapeMap = new Hashtable<String, Animal>();
	
	/**
	 * @param name
	 */
	public static Animal getAnimal(String name) {
		Animal animal = shapeMap.get(name);
		return (Animal) animal.clone();
	}
	
	public static void loadAnimal(){
		//系统启动时候可以注入进来
		shapeMap.put("dog", new Dog());
	}
		
}
